package models

import (
	"shop-microservices/basic/inits"
	"time"
)

type Carousel struct {
	Id           uint32    `gorm:"column:id;type:int UNSIGNED;primaryKey;not null;" json:"id"`
	SliderImage  string    `gorm:"column:slider_image;type:varchar(255);comment:轮播图;not null;" json:"slider_image"`                                // 轮播图
	Title        string    `gorm:"column:title;type:varchar(255);comment:标题;not null;" json:"title"`                                               // 标题
	Status       uint8     `gorm:"column:status;type:tinyint UNSIGNED;comment:1上架 2下架;not null;default:1;" json:"status"`                          // 1上架 2下架
	CarouselType uint8     `gorm:"column:carousel_type;type:tinyint UNSIGNED;comment:1 自动轮播 2手动轮播 3混合轮播;not null;default:1;" json:"carousel_type"` // 1 自动轮播 2手动轮播 3混合轮播
	CreatedAt    time.Time `gorm:"column:created_at;type:date;comment:创建时间;not null;" json:"created_at"`                                           // 创建时间
}

func (c *Carousel) TableName() string {
	return "carousel"
}
func (c *Carousel) CarouselList() (list []Carousel, err error) {
	inits.DB.Find(&list)
	return
}
